package android.slc.user.ui.dept.adapter

import android.slc.adapter.SelectBox
import android.slc.extras.user.entity.SysDept
import android.slc.user.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.module.LoadMoreModule
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.google.android.material.checkbox.MaterialCheckBox

/**
 * @author slc
 * @date 2020-08-24 16:18
 */
class DeptMultipleAdapter(data: MutableList<SelectBox<SysDept>>) :
    BaseQuickAdapter<SelectBox<SysDept>, BaseViewHolder>(
        R.layout.user_item_dept_info_select_multiple,
        data
    ),
    LoadMoreModule {
    private val deptBrowserProvider = DeptBrowserProvider()

    init {
        addChildClickViewIds(R.id.checkbox)
    }

    override fun convert(holder: BaseViewHolder, item: SelectBox<SysDept>) {
        deptBrowserProvider.convert(holder, item.data)
        holder.getView<MaterialCheckBox>(R.id.checkbox).isChecked = item.isChecked
    }

}